package com.hubei.controller;

import com.hubei.pojo.User;
import com.hubei.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(value = "/list.action")
    public String queryUserList(Model model){
        List<User> userList = userService.queryUserList();
        model.addAttribute("userList", userList);
        return "user_list";
    }

    @RequestMapping("/add.action")
    public String userAdd(){
        User user = new User(1,"阿斯蒂芬规划局快乐阿萨斯凤凰国际","男男女女");
        userService.addUser(user);
        return "user_add";
    }
}
